package com.cssy.yd.basic.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.yd.basic.dao.BasicBomInfoDAO;
import com.cssy.yd.basic.entity.BasicBomInfoDO;
import com.cssy.yd.basic.entity.BasicBomRawMaterialDO;
import com.cssy.yd.basic.entity.BasicMaterialsDO;
import com.cssy.yd.basic.service.IBasicBomInfoService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;

@Service("basicBomInfoService")
public class BasicBomInfoServiceImpl implements IBasicBomInfoService {

	@Resource(name="basicBomInfoDAO")
	private BasicBomInfoDAO basicBomInfoDAO;
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicBomInfoDO>  list=basicBomInfoDAO.find(scs);
		rs.setRecordCount(basicBomInfoDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		basicBomInfoDAO.deleteBasicBomInfoDOByPrimaryKey(id);
		return null;
	}

	@Override
	public Integer update(BasicBomInfoDO t, User user) throws SyBaseException {
		t.setDuuser(user.getName());
		t.setDutime(new Date());
		return basicBomInfoDAO.updateBasicBomInfoDO(t);
	}

	@Override
	public BasicBomInfoDO save(BasicBomInfoDO t, User user)
			throws SyBaseException {
		t.setDcruser(user.getName());
		t.setDctime(new Date());
		t.setBillSequenceId(IDCodeTypeUtil.getId());
		basicBomInfoDAO.insertBasicBomInfoDO(t);
		return t;
	}

	@Override
	public BasicBomInfoDO findListById(String id) throws SyBaseException {
		return basicBomInfoDAO.findBasicBomInfoDOByPrimaryKey(id);
	}

	@Override
	public List<BasicBomInfoDO> findListByExample(BasicBomInfoDO basicBomInfoDO)
			throws SyBaseException {
		
		return basicBomInfoDAO.findListByExample(basicBomInfoDO);
	}

	@Override
	public List<BasicMaterialsDO> findCpByExample(Map<String, Object> map) throws SyBaseException {
		// TODO Auto-generated method stub
		return basicBomInfoDAO.findAllCp(map);
	}

	@Override
	public List<BasicBomRawMaterialDO> findRawMaterialByExample(
			String code) throws SyBaseException {
		// TODO Auto-generated method stub
		return basicBomInfoDAO.findRawMaterials(code);
	}

	@Override
	public List<BasicBomRawMaterialDO> findSubstituteByExample(Map<String, Object> map)
			throws SyBaseException {
		// TODO Auto-generated method stub
		return basicBomInfoDAO.findSubstituteAll(map);
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

}
